void solve()
{
  int n;
  cin >> n;

  queue<tuple<int, int, int>> Q;
  
  auto ask = [&](int p, int q) {
    cout << "? " << p << ' ' << q << endl;
    int g;
    cin >> g;
    return g;  
  };

  Q.push({1, 2, ask(1, 2)});
  rep(i, 3, n) {
    auto [p, q, g1] = Q.front();
    Q.pop();

    int g2 = ask(p, i);
    int g3 = ask(q, i);
    int g4 = max({g1, g2, g3});

    if (g4 == g1) {
      Q.push({p, q, g1});
    } else if (g4 == g2) {
      Q.push({p, i, g2});
    } else {
      Q.push({q, i, g3});
    }
  }

  cout << "! " << get<0>(Q.front()) << ' ' << get<1>(Q.front()) << endl;
  int d;
  cin >> d;
  if (d == -1) {
    exit(0);
  }
}